$.get(
  "http://chst.vip:1234/api/getbaicaijiatitle",
  {},
  (res) => {
    let html = "";
    $(res.result).each((i, item) => {
      html += `<li titleId=${item.titleId} >${item.title}</li>`;
    });
    $(".contenttop").html(html);
  },
  "json"
);
let num = 0;

function Auto(num) {
  $.get(
    "http://chst.vip:1234/api/getbaicaijiaproduct",
    { titleid: num },
    (res) => {
      let html = "";
      $(res.result).each((i, item) => {
        html += `<li> 
      ${item.productImg}
      <div>
      <h3>
            ${item.productName}
      </h3>
      <h4>
      ${item.productPrice}
         </h4>
         <h5>
         ${item.productCouponRemain}
         </h5>

         <h6>
         ${item.productCoupon}
         </h6>

      </div>
      <button>下单链接</button>


      </li>
        `;
      });
      $(".contentbottom").html(html);
    },
    "json"
  );
}
//调用
Auto(num);
//添加事件
$(".contenttop").on("click", "li", function () {
  console.log($(".contenttop"));

  num = Number($(this).attr("titleId"));
  Auto(num);
});
